package com.gitee.ixtf.vertx

import graphql.schema.DataFetchingEnvironment
import io.vertx.core.eventbus.Message
import io.vertx.ext.web.RoutingContext
import java.lang.reflect.Parameter
import java.lang.reflect.Type

interface ParameterConverter<T> {
  suspend fun convert(env: DataFetchingEnvironment): T = throw IllegalAccessError()

  suspend fun convert(rc: RoutingContext): T = throw IllegalAccessError()

  suspend fun convert(message: Message<*>): T = throw IllegalAccessError()
}

interface ParameterConverterProvider {
  fun <T> getConverter(
      parameter: Parameter,
      rawType: Class<T>,
      genericType: Type?,
      annotations: Array<Annotation>?
  ): ParameterConverter<T>?
}
